package com.example.base.util.validator;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.example.base.entity.Chapter;
import com.example.base.util.Response;

import java.util.ArrayList;
import java.util.List;

public class ChapterCtrlValidate {

    public static void getChapterValidate(Chapter chapter, Response response) {
        response.setMsg("课程信息添加失败");
        response.setStatus(400);
        response.setData(0);

        List<String> params = new ArrayList<>();

        if (ObjectUtils.isEmpty(chapter.getCourseId()))
            params.add("courseId");

        if (params.size() >= 1) {
            String formatParams = String.join(",", params);
            response.setError("Required String parameter '" + formatParams + "' is not present");
        } else {
            response.setMsg("课程信息添加成功");
            response.setStatus(200);
        }
    }
    
}
